package com.yitiao.data_algorithms.leetcode.editor.cn;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;

class FanZhuanLianBiaoLcof{
    //leetcode submit region begin(Prohibit modification and deletion)
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public ListNode reverseList(ListNode head) {
        ListNode cur = head;
        ListNode ans = null;
        while (cur!=null){
            ListNode next = cur.next;
            cur.next = ans;

            ans = cur;

            cur = next;

        }
        return ans;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}